package com.zhuss.car.driver;

import com.zhuss.bean.bo.car.driver.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;

/**
 * @description: 司机操作的Service
 * @author: zhushanshuo
 * @create: Mon Dec 21 13:31:45 CST 2020
 **/
@Component("driverOperateService")
public class DriverOperateService implements OperateService<Void, Object> {

	@Autowired
	@Qualifier("driverCreate")
	private Processor<Object, CreateDriverBo> driverCreate;

	@Autowired
	@Qualifier("driverUpdate")
	private Processor<Object, UpdateDriverBo> driverUpdate;

	@Autowired
	@Qualifier("driverDelete")
	private Processor<Object, DeleteDriverBo> driverDelete;

	@Autowired
	@Qualifier("driverStart")
	private Processor<Object, StartDriverBo> driverStart;

	@Autowired
	@Qualifier("driverStop")
	private Processor<Object, StopDriverBo> driverStop;


	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws DzcxException {

		CreateDriverBo bo = (CreateDriverBo) param;

		driverCreate.process(bo);

		return null;
	}

	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws DzcxException {

		UpdateDriverBo bo = (UpdateDriverBo) param;

		driverUpdate.process(bo);

    	return null;
    }

	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws DzcxException {

		DeleteDriverBo bo = (DeleteDriverBo) param;

		driverDelete.process(bo);

		return null;
	}

	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void start(Object param) throws DzcxException {

		StartDriverBo bo = (StartDriverBo) param;

		driverStart.process(bo);

		return null;
	}

	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws DzcxException {

		StopDriverBo bo = (StopDriverBo) param;

		driverStop.process(bo);

		return null;
	}


}

